{% extends 'admin/extende/base.html' %}

{% block title %}
<title>会员列表</title>
{% endblock %}


{% block context %}
    <div class="container-fluid am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                <div class="page-header-heading"><span class="am-icon-home page-header-heading-icon"></span>会员列表</div>
            </div>
        </div>
    </div>

    <div class="widget-body  am-fr">
        <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
            <div class="am-form-group">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <button type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> 新增</button>
                        <button type="button" class="am-btn am-btn-default am-btn-secondary"><span class="am-icon-save"></span> 保存</button>
                        <button type="button" class="am-btn am-btn-default am-btn-warning"><span class="am-icon-archive"></span> 审核</button>
                        <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>
                    </div>
                </div>
            </div>
        </div>
        <form action="" method="get">
            <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                <div class="am-form-group tpl-table-list-select">
                    <select name="types" data-am-selected="{btnSize: 'sm'}" style="display: none;">
                          <option {% if request.GET.types == 'all' %} selected {% endif %} value="all">所有类别</option>
                          <option {% if request.GET.types == 'username' %} selected {% endif %} value="username">用户名</option>
                          <option {% if request.GET.types == 'email' %} selected {% endif %} value="email">邮箱</option>
                          <option {% if request.GET.types == 'phone' %} selected {% endif %} value="phone">手机号</option>
                          <option {% if request.GET.types == 'age' %} selected {% endif %} value="age">年龄</option>
                    </select>
                </div>
            </div>
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                    <input name="keywords" value="{{ request.GET.keywords }}" type="text" class="am-form-field ">
                    <span class="am-input-group-btn">
                        <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search"></button>
                    </span>
                </div>
            </div>
        </form>
        <div class="am-u-sm-12">
            <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black ">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>头像</th>
                        <th>用户名</th>
                        <th>手机号</th>
                        <th>邮箱</th>
                        <th>年龄</th>
                        <th>性别</th>
                        <th>注册时间</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for v in data %}
                    <tr class="gradeX">
                        <td class="am-text-middle">{{ v.id }}</td>
                        <td>
                            <img src="{{ v.pic }}" class="tpl-table-line-img" alt="" height="48" >
                        </td>
                        <td class="am-text-middle">{{ v.username }}</td>
                        <td class="am-text-middle">{{ v.phone }}</td>
                        <td class="am-text-middle">{{ v.email }}</td>
                        <td class="am-text-middle">{{ v.age }}</td>
                        <td class="am-text-middle">
                            {% if v.sex == 0 %} 女
                            {% elif v.sex == 1 %} 男
                            {% endif %}
                        </td>
                        <td class="am-text-middle">{{ v.addtime|date:'Y-m-d H:i:s'  }}</td>
                        <td class="am-text-middle">
                            {% if v.status == 0 %} 正常
                            {% elif v.status == 1 %} 禁用
                            {% endif %}
                        </td>
                        <td class="am-text-middle">
                            <div class="tpl-table-black-operation">
                                <a href="{% url 'admin_user_uppage' v.id %}">
                                    <i class="am-icon-pencil"></i> 编辑
                                </a>
                                <a href="{% url 'admin_user_del' %}?uid={{ v.id }}" class="tpl-table-black-operation-del">
                                    <i class="am-icon-trash"></i> 删除
                                </a>
                            </div>
                        </td>
                    </tr>
                    {% endfor %}
                    <!-- more data -->
                </tbody>
            </table>
        </div>
        <div class="am-u-lg-12 am-cf">

            <div class="am-fr">
                <ul class="am-pagination tpl-pagination">
{#                    <li class="am-disabled"><a href="#">«</a></li>#}
{#                    <li class="am-active"><a href="#">1</a></li>#}
                    <!--引入 字定义标签 {# load 标签文件名 #}-->
                    {% load pagetag %}

                    <!--使用 字定义标签   {# {% 标签名 参数1(总页数) 参数2(通过request获取页码) %} #}
                    通过分配的 数据源（data）找到 分页对象(paginator) 调用分页对象内的 分页总数(num_pages) 获得分页总数
                     request:请求对象： 传给标签用于获取 GEt 地址的 page(当前页码)
                       -->
                    {% showpage data.paginator.num_pages request %}
{#                    <li><a href="#">»</a></li>#}
                </ul>
            </div>
        </div>
    </div>
{% endblock %}